﻿/*
 * Created by SharpDevelop.
 * User: Dani
 * Date: 2013.12.08.
 * Time: 20:08
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;

namespace BK
{
	class Program
	{
		public static void Main(string[] args)
		{
Console.Title = "Boldog Karácsonyt";
			/*
1 db 	50 000 000 Ft == n14
2 db 	5 000 000 Ft == n13
20 db 	100 000 Ft == n12
30 db 	50 000 Ft == n11
1 000 db 	20 000 Ft == n10
1 500 db 	11 000 Ft == n9
7 000 db 	10 000 Ft == n8
7 000 db 	8 000 Ft == n7
9 000 db 	6 000 Ft == n6
20 000 db 	5 000 Ft == n5
40 000 db 	4 000 Ft == n4
40 000 db 	3 000 Ft == n3
200 000 db 	2 000 Ft == n2
280 000 db 	1 000 Ft == n1
Total: 2.000.000.
*/
scratch:
Console.Clear();
int n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14;
double c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14;
const int IN_PERCENT = 100;
n1 = 280000;
n2 = 200000;
n3 = 40000;
n4 = 40000;
n5 = 20000;
n6 = 9000;
n7 = 7000;
n8 = 7000;
n9 = 1500;
n10 = 1000;
n11 = 30;
n12 = 20;
n13 = 2;
n14 = 1;
p14 = 50000000;
p13 = 5000000;
p12 = 100000;
p11 = 50000;
p10 = 20000;
p9 = 11000;
p8 = 10000;
p7 = 8000;
p6 = 6000;
p5 = 5000;
p4 = 4000;
p3 = 3000;
p2 = 2000;
p1 = 1000;
uint totalgames = 1;
uint initialMoney = 5000;
uint games = 2000000;
int balance = 0;
bool won = false;
int curMoney = 5000;
bool debug = false;
Random rng = new Random();
/*Console.Write("Starter Money: ");
initialMoney = uint.Parse(Console.ReadLine());*/
Console.Write("Szimulációk száma: ");
totalgames = uint.Parse(Console.ReadLine());
//curMoney = initialMoney;

/*int sumN = n1+n2+n3+n4+n5+n6+n7+n8+n9+n10+n11+n12+n13+n14;
double chances = ((double)sumN / (double)games) *100;
Console.WriteLine("{0}",chances);*/
c1 = ((double)n1 / (double)games) * IN_PERCENT;
c2 = ((double)n2 / (double)games) * IN_PERCENT;
c3 = ((double)n3 / (double)games) * IN_PERCENT;
c4 = ((double)n4 / (double)games) * IN_PERCENT;
c5 = ((double)n5 / (double)games) * IN_PERCENT;
c6 = ((double)n6 / (double)games) * IN_PERCENT;
c7 = ((double)n7 / (double)games) * IN_PERCENT;
c8 = ((double)n8 / (double)games) * IN_PERCENT;
c9 = ((double)n9 / (double)games) * IN_PERCENT;
c10 = ((double)n10 / (double)games) * IN_PERCENT;
c11 = ((double)n11 / (double)games) * IN_PERCENT;
c12 = ((double)n12 / (double)games) * IN_PERCENT;
c13 = ((double)n13 / (double)games) * IN_PERCENT;
c14 = ((double)n14 / (double)games) * IN_PERCENT;
c13 = c13 + c14;
c12 = c12 + c13;
c11 = c11+ c12;
c10 = c10 + c11;
c9 = c9 + c10;
c8 = c8 + c9;
c7 = c7 + c8;
c6 = c6 + c7;
c5 = c5 + c6;
c4 = c4 + c5;
c3 = c3 + c4;
c2 = c2 + c3;
c1 = c1 + c2;
double least = (double)c14;
//Console.WriteLine(c1+" "+c2+" "+c3+" "+c4+" "+c5+" "+c6+" "+c7+" "+c8+" "+c9+" "+c10+" "+c11+" "+c12+" "+c13+" "+c14);
//Console.WriteLine(c14);
Console.WriteLine("Press a key to scratch");
c1 = ((double)n1 / (double)games) * IN_PERCENT;
c2 = ((double)n2 / (double)games) * IN_PERCENT;
c3 = ((double)n3 / (double)games) * IN_PERCENT;
c4 = ((double)n4 / (double)games) * IN_PERCENT;
c5 = ((double)n5 / (double)games) * IN_PERCENT;
c6 = ((double)n6 / (double)games) * IN_PERCENT;
c7 = ((double)n7 / (double)games) * IN_PERCENT;
c8 = ((double)n8 / (double)games) * IN_PERCENT;
c9 = ((double)n9 / (double)games) * IN_PERCENT;
c10 = ((double)n10 / (double)games) * IN_PERCENT;
c11 = ((double)n11 / (double)games) * IN_PERCENT;
c12 = ((double)n12 / (double)games) * IN_PERCENT;
c13 = ((double)n13 / (double)games) * IN_PERCENT;
c14 = ((double)n14 / (double)games) * IN_PERCENT;
c13 = c13 + c14;
c12 = c12 + c13;
c11 = c11+ c12;
c10 = c10 + c11;
c9 = c9 + c10;
c8 = c8 + c9;
c7 = c7 + c8;
c6 = c6 + c7;
c5 = c5 + c6;
c4 = c4 + c5;
c3 = c3 + c4;
c2 = c2 + c3;
c1 = c1 + c2;
//--------------------[Actual Scratching]--------------------------------
for(int i = 0; i < totalgames; i++)
{//for
//Console.WriteLine(least);
double asd = least + rng.NextDouble() * 100;
//Console.WriteLine(asd);
balance -= 1000;
if(asd == c14)
{
	won = true;
	Console.WriteLine("Nyereményed: "+p14);
	n14 --;
	balance += p14;
	//TODO: Reduce ticket ammount (n14 number) && much more 

}
else if(asd < c13 && asd > c14)
{
	won = true;
	Console.WriteLine("Nyereményed: "+p13);
	n13 --;
	balance += p13;
}
else if(asd < c12 && asd > c13)
{
	won = true;
	Console.WriteLine("Nyereményed: "+p12);
	n12 --;
	balance += p12;
}
else if(asd < c11 && asd > c12)
{
	won = true;
	Console.WriteLine("Nyereményed: "+p11);
	n11 --;
	balance += p11;
}
else if(asd < c10 && asd > c11)
{
	won = true;
	Console.WriteLine("Nyereményed: "+p10);
	n10 --;
	balance += p10;
}
else if(asd < c9 && asd > c10)
{
	won = true;
	Console.WriteLine("Nyereményed: "+p9);
	n9 --;
	balance += p9;

}
else if(asd < c8 && asd > c9)
{
	won = true;
	Console.WriteLine("Nyereményed: "+p8);
	n8 --;
	balance += p8;
}
else if(asd < c7 && asd > c8)
{
	won = true;
	Console.WriteLine("Nyereményed: "+p7);
	n7 --;
	balance += p7;
}
else if(asd < c6&& asd > c7)
{
	won = true;
	Console.WriteLine("Nyereményed: "+p6);
	n6 --;
	balance += p6;
}
else if(asd < c5 && asd > c6)
{
	won = true;
	Console.WriteLine("Nyereményed: "+p5);
	n5 --;	
	balance += p5;
}
else if(asd < c4 && asd > c5)
{
	won = true;
	Console.WriteLine("Nyereményed: "+p4);
	n4 --;
	balance += p4;
}
else if(asd < c3 && asd > c4)
{
	won = true;
	Console.WriteLine("Nyereményed: "+p3);
	n3 --;
	balance += p3;
}
else if(asd < c2 && asd > c3)
{
	won = true;
	Console.WriteLine("Nyereményed: "+p2);
	n2 --;
	balance += p2;
}
else if(asd < c1 && asd > c2)
{
	won = true;
	Console.WriteLine("Nyereményed: "+p1);
	n1 --;
	balance += p1;
}
else
{
	won = false;
	Console.WriteLine("Nyereményed: 0");

}
games --;
}//[/for]
//Console.WriteLine(asd);
Console.WriteLine("==================================================================\n{0} sorsjegy szimulálva. Tiszta haszon: {1} ft. "/*(Induló összeg: {2} ft)"*/,totalgames, balance/*, curMoney*/);
Console.ReadKey(true);
goto scratch;
			Console.ReadKey(true);
		}
	}
}